package com.pearadmin.pro.modules.school.rest;

import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import com.pearadmin.pro.modules.school.domain.CourseBasicInformation;
import com.pearadmin.pro.modules.school.dto.CourseBasicInformationDTO;
import com.pearadmin.pro.modules.school.param.CourseBasicInformationRequest;
import com.pearadmin.pro.modules.school.service.CourseBasicInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 课程基本信息Controller
 *
 * @author ChenJian
 * @date 2021-08-29
 */
@Api(tags = {"课程基本信息"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"courseBasicInformation/courseBasicInformation")
public class CourseBasicInformationController extends BaseController
{
    @Resource
    private CourseBasicInformationService courseBasicInformationService;

    /**
     * 查询课程基本信息列表
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "课程基本信息列表")
    @ApiOperation(value = "课程基本信息列表")
    public Result<CourseBasicInformation> list(CourseBasicInformationRequest courseBasicInformationRequest)
    {
        return success(courseBasicInformationService.page(courseBasicInformationRequest));
    }


    /**
     * 新增保存课程基本信息
     * @param courseBasicInformation 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增课程基本信息")
    @ApiOperation(value = "新增课程基本信息")
    public Result save(@RequestBody CourseBasicInformationDTO courseBasicInformation)
    {
        return auto(courseBasicInformationService.saveOrUpdate(courseBasicInformation));
    }

    /**
     * 查询课程基本信息详情
     *
     * @param id 课程基本信息ID
     * @return 课程基本信息
     */
    @GetMapping("/selectById")
    @Log(title = "查询课程基本信息详情")
    @ApiOperation(value = "查询课程基本信息详情")
    public Result<CourseBasicInformation> selectById(@RequestParam Long id)
    {
        return success(courseBasicInformationService.selectCourseBasicInformationById(id));
    }



    /**
     * 修改保存课程基本信息
     * @param courseBasicInformation 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改课程基本信息")
    @ApiOperation(value = "修改课程基本信息")
    public Result update(@RequestBody CourseBasicInformationDTO courseBasicInformation)
    {
        return auto(courseBasicInformationService.saveOrUpdate(courseBasicInformation));
    }


    /**
     * 删除保存课程基本信息
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除课程基本信息")
    @ApiOperation(value = "删除课程基本信息")
    public Result remove(@RequestParam Long id)
    {
        return auto(courseBasicInformationService.removeById(id));
    }

    /**
    * 批量删除课程基本信息
    * @param ids 批量删除
    * @return {@link Result}
    */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除课程基本信息")
    @ApiOperation(value = "批量删除课程基本信息")
    public Result removeBatch(@RequestParam List<Long> ids){
        return auto(courseBasicInformationService.removeByIds(ids));
    }

}
